using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
         
        GetPropertyOfControlInUserControl();
        GetPublicVariableAndProperty();
        LoadControlToASPPage();
        LoadUserControlToASPPage();
    }
    void LoadUserControlToASPPage()
    {
        string data = Request.QueryString.Get("data");
        string ascx = "home,search,product,contact,sitemap";
        Control control;
        if (data != null && ascx.IndexOf(data) != -1)
        {
            control = this.LoadControl(data+".ascx");
           
        }
        else
            control = this.LoadControl("home.ascx");
        panelBody.Controls.Add(control);    
    }
    void GetPropertyOfControlInUserControl()
    {
        HyperLink hyperLink = (HyperLink)
        this.Left1.FindControl("huukhang");
        Literal1.Text = hyperLink.Text;
        Literal2.Text = hyperLink.NavigateUrl;
    }
    void GetPublicVariableAndProperty()
    {
        Literal3.Text = this.Left1.pageSize.ToString();
        Literal4.Text = this.Left1.SelectQuery;
    }
    void LoadControlToASPPage()
    {
        Control  control = this.LoadControl("menu.ascx");
        panelMenu.Controls.Add(control);
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        foreach(Control control in this.panelBody.Controls)
        {
            if(control is UserControl)
            {
                UserControl userControl = (UserControl) control;
                Literal5.Text += userControl.ToString() + "<br>";
            }
        }
    }
}
